package com.mz.ozy.mvp.model;

import android.content.Context;

import com.mz.ozy.constants.Constants;
import com.mz.ozy.net.RetrofitUtils;

import java.util.HashMap;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

public class AccountSetModel {

    public Observable<ResponseBody> onMe(Context context) {
        HashMap<String, String> map = new HashMap<>();
        map.put("t", Constants.tokenId);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10003, map);
    }


    /**
     * 修改个人信息
     * @param context
     * @param type  类型(1修改头像2修改昵称3修改所在地区)"
     * @param name
     * @return
     */
    public Observable<ResponseBody> onUpdate(Context context, int type, String name) {
        HashMap<String, String> map = new HashMap<>();
        map.put("type",type+"");
        map.put("name", name);
        map.put("t",Constants.tokenId);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10005, map);
    }

    /**
     * 退出登录
     * @param context
     * @return
     */
    public Observable<ResponseBody> onLogout(Context context) {
        HashMap<String, String> map = new HashMap<>();
        map.put("t",Constants.tokenId);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10010, map);
    }


    /**
     * 取消绑定
     * @param context
     * @param type     1-微信  2-支付宝
     * @return
     */
    public Observable<ResponseBody> onCancelBind(Context context, int type) {
        HashMap<String, String> map = new HashMap<>();
        map.put("type",type+"");
        map.put("t",Constants.tokenId);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10044, map);
    }


    /**
     * 获得支付宝授权
     * @param context
     * @return
     */
    public Observable<ResponseBody> onGetAlipayAuth(Context context){
        HashMap<String, String> map = new HashMap<>();
        map.put("t",Constants.tokenId);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10038, map);
    }

    /**
     * 微信or支付宝  授权绑定
     * @param context
     * @param type       1-微信 2-支付宝
     * @return
     */
    public Observable<ResponseBody> onAuthBind(Context context, int type, String id) {
        HashMap<String, String> map = new HashMap<>();
        map.put("type", type+"");
        map.put("id", id);
        map.put("t",Constants.tokenId);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10046, map);
    }

}